<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('news/index')}">项目动态</a></li>
			<if condition="($level eq '0' OR $level eq '1')">
				<li><a href="{:U('news/add')}">添加动态</a></li>
			</if>
		</ul>


        <form class="well form-search  form-inline" method="post" action="{:U('news/index')}">
            <div class="form-group">
                <label class="sr-only">标题</label>
                <input type="text" name="title" class="form-control" value="{:I('request.title/s','')}" placeholder="输入标题名称查找...">
            </div>
            <button class="btn btn-primary" type="submit">搜索</button>
            <a class="btn btn-danger" href="{:U('news/index')}">清空</a>
        </form>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th>标题</th>
					<th>来源</th>
					<th style="width:60px;">访问量</th>
					<th style="width:80px;">创建人</th>
					<th>创建时间</th>
                    <th>是否发布</th>
					<th width="120">{:L('ACTIONS')}</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="results" item="vo">
				<tr>
					<td>{$vo.title}</td>
					<td>{$vo.source}</td>
					<td>{$vo.hits_count}</td>
					<td>{$vo.real_name}</td>
					<td>
						<php>
							echo date("Y-m-d h:m",strtotime($vo['add_time']));
						</php>
					</td>
                    <td class="text-center">
                        <if condition="$vo['is_publish'] eq 1">
                            <i class="glyphicon glyphicon-ok text-success"></i>
                            <else />
                            <i class="glyphicon glyphicon glyphicon-remove text-danger"></i>
                        </if>
                    </td>
					<td>
                        <a href="{:U('News/view',array('id'=>$vo['id']))}">查看</a>
                        <if condition="$vo['is_publish'] eq 0">
                        |
                        <a href='{:U("News/edit", array("id"=>$vo["id"]))}'>修改</a>
                        |
                        <a class="js-ajax-delete" href="{:U('News/delete',array('id'=>$vo['id']))}">删除</a>
                        </if>

                        <if condition="$vo['is_publish'] eq 1 and $level eq 0">
                        |
                        <a class="js-ajax-delete" href="{:U('News/delete',array('id'=>$vo['id']))}">删除</a>
                        </if>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">


function ajaxtest(){
	$.ajax({
				url : 'index.php?g=Admin&m=news&a=iii',
				secureuri : false, //安全协议
				
				type : 'post',
				dataType : 'json',
				data:{
					'num'   : 1
				},
				error : function(data,status,e) {
					alert("服务器内部错误！");
				},
				success : function(json){
					console.log(json);	
				}
			});
}

		function UploadFile(reqUrl, folder){
			if($("#upFile").val() == ""){
				alert("请选择待上传文件！");
				return false;
			}
			$.ajax({
				url : reqUrl,
				secureuri : false, //安全协议
				fileElementId:'upFile', //id
				type : 'post',
				dataType : 'json',
				data:{
					'folder'   : folder,
					'ajax': 1
				},
				error : function(data,status,e) {
					alert("服务器内部错误！");
				},
				success : function(json){
					if (json.rtnType == 'T'){
						html = "<div class='controls' style='margin-top:10px;'>   \n"
							+ "	<input type='hidden' name='filePath[]' value="+json.rtnResult+" />    \n"
							+ "	<input type='hidden' name='fileName[]' value="+json.file_name+" />    \n"
							+ "	<input type='hidden' name='file_size[]' value="+json.file_size+" />   \n"
							+ "	<input type='hidden' name='postfix[]' value="+json.postfix+" />     \n"
							+ "	<label>"+json.file_name+"</label>                              \n"
							+ "	<a href='javascript:void(0)' class='delFile'>删除</a> \n"
							+ "</div>";
						$(".controls:last").after(html);
					} else {
						alert(json.rtnMsg);
					}
				},
				complete: function(xmlHttpRequest) {
					$("#upFile").replaceWith('<input type="file" id="upFile" name="upFile" style="display:none" />');
					$("#upFile").on("change", function(){
						UploadFile(reqUrl, rtnFun, belong, folder);
					});
				}
			});
		}
	</script>
</body>
</html>